/**
 * @param {number} radius
 * @param {number} x_center
 * @param {number} y_center
 */
export var Solution = function (radius, x_center, y_center) {
  this.radius = radius
  this.x_center = x_center
  this.y_center = y_center
}

/**
 * @return {number[]}
 */
Solution.prototype.randPoint = function () {
  // eslint-disable-next-line no-constant-condition
  while (true) {
    const x = Math.random() * 2 * this.radius - this.radius
    const y = Math.random() * 2 * this.radius - this.radius
    if (this.getDistance(x, y, 0, 0) <= this.radius) {
      return [x + this.x_center, y + this.y_center]
    }
  }
}

Solution.prototype.getDistance = function (x0, y0, x1, y1) {
  return Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1))
}

/**
 * Your Solution object will be instantiated and called as such:
 * var obj = new Solution(radius, x_center, y_center)
 * var param_1 = obj.randPoint()
 */
